Skip to content

ZCF-3300 <feature>[license]: support license lsclient#3893

Open
zstack-robot-1 wants to merge 2 commits intofeature-5.5.22-zcf-temporaryfrom
sync/hanyu.liang/zcf-3300@@2
Open

ZCF-3300 <feature>[license]: support license lsclient#3893
zstack-robot-1 wants to merge 2 commits intofeature-5.5.22-zcf-temporaryfrom
sync/hanyu.liang/zcf-3300@@2

Conversation

@zstack-robot-1
Copy link
Copy Markdown
Collaborator

Summary

  • Support testlib routing for LS client endpoints under /v1/sites/** and /v1/quota/**.
  • Support multipart request parsing in testlib for LS bootstrap API coverage.

Jira

Verification

  • testlib module compile passed during development.
  • premium integration cases covering LS client lifecycle and quota behavior passed in companion MR.

sync from gitlab !9775

Support testlib simulator routing and multipart parsing for License Server client API tests.

Resolves: ZCF-3300

Change-Id: I4a80faaf48aa174bebc5186b8b76033a9b6968b7
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: ce25353e-23e0-4347-8159-dbd293e5e1a4

📥 Commits

Reviewing files that changed from the base of the PR and between c0a9d03 and 9438a58.

📒 Files selected for processing (1)
  • testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy
🚧 Files skipped from review as they are similar to previous changes (1)
  • testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy

Walkthrough

该PR为TestLibController扩展路由并在控制器层检测并短路multipart请求;EnvSpec新增multipart感知的请求体读取与序列化,并调整getEntityFromRequest的头部/体构建顺序。

多部分请求处理

Layer / File(s) Summary
路由配置
testlib/src/main/java/org/zstack/testlib/TestLibController.java
@RequestMapping扩展为包含/v1/sites/**/v1/quota/**并保留catch-all。
多部分检测
testlib/src/main/java/org/zstack/testlib/TestLibController.java
新增私有isMultipartRequest(HttpServletRequest),通过Content-Type前缀multipart/识别多部分请求。
请求分发
testlib/src/main/java/org/zstack/testlib/TestLibController.java
控制器处理器对multipart请求早期返回,直接委托Test.handleHttp(request,response);非multipart保持原异步路径。
请求体提取
testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy
getEntityFromRequest先收集头部,再根据Content-Type分支:multipart使用multipart读取,其他通过req.getReader()按行读取并关闭。
多部分解析实现
testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy
新增readMultipartBodyreadSpringMultipartBodyappendMultipartPart以读取原始输入或委托Spring并将各part/file序列化为一致文本格式。

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant TestLibController
  participant TestHandler
  participant EnvSpec
  participant AsyncHandler
  Client->>TestLibController: HTTP request
  TestLibController->>TestLibController: isMultipartRequest?
  alt multipart
    TestLibController->>TestHandler: Test.handleHttp(request,response)
    TestHandler-->>Client: response
  else non-multipart
    TestLibController->>AsyncHandler: enqueue async handling
    AsyncHandler->>EnvSpec: getEntityFromRequest(req)
    EnvSpec->>EnvSpec: collect headers
    EnvSpec->>EnvSpec: read body (multipart? -> multipart reader : reader lines)
    EnvSpec-->>AsyncHandler: HttpEntity<String>
    AsyncHandler-->>Client: response
  end
Loading

代码审查工作量估计

🎯 3 (中等复杂度) | ⏱️ ~22 分钟

庆祝诗

🐰 多部分之梦在此成真,
请求流转如丝线纷纷,
控制器先问 Content-Type,
解析层把每段写成文,
字节与表单终有归根。


Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 error)

Check name Status Explanation Resolution
Title check ❌ Error 标题格式不符合要求。应为 '[scope]: ' 格式,但当前标题包含 'ZCF-3300' 前缀,不符合规范。 移除 'ZCF-3300' 前缀,将标题改为 '[testlib]: support multipart request parsing and LS client routing' 的格式。
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed 描述清晰地说明了变更内容,包括添加的功能(支持 LS 客户端路由和多部分请求解析)和验证情况。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sync/hanyu.liang/zcf-3300@@2

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy`:
- Around line 1001-1006: The code repeatedly calls req.getReader() causing
potential inconsistent reads; change to obtain a single BufferedReader reader =
req.getReader() (or def reader) before the loop, use that reader in the while
loop that appends lines (instead of calling req.getReader().readLine()), and
ensure the reader is closed in a finally block (or try-with-resources) to
guarantee a single, safe close; update the block around the loop in
EnvSpec.groovy where String line is used so all read/close operations reference
this single reader variable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: http://open.zstack.ai:20001/code-reviews/zstack-cloud.yaml (via .coderabbit.yaml)

Review profile: CHILL

Plan: Pro

Run ID: a0e468ad-d803-4c32-9c4d-87a474a162a0

📥 Commits

Reviewing files that changed from the base of the PR and between 7f86605 and c0a9d03.

📒 Files selected for processing (2)
  • testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy
  • testlib/src/main/java/org/zstack/testlib/TestLibController.java

Comment thread testlib/src/main/java/org/zstack/testlib/EnvSpec.groovy Outdated
Resolves: ZCF-3300

Change-Id: Ice0313a96e9c4c72adbd9d2f6f52e832fe590bbc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants